package com.Smart.smartscals.HttpTools;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.Smart.smartscals.Entity.EntityModification;
import com.Smart.smartscals.Entity.EntityParmToNet;
import com.Smart.smartscals.Entity.EntityRegist;
import com.Smart.smartscals.Entity.EntityRemoverData;
import com.Smart.smartscals.Entity.EntityUploadData;

/**
 * 此类用于用户注册、登录、修改等功能的数据封装
 * 
 * @author Administrator
 * 
 */
public class ValidateFormat {
	/**
	 * 注册信息封装方法 在此App中只有PhoneNum, userName,password, mSex,
	 * Birthday,UserHeight六个参数 其他都为null
	 * 
	 * @return
	 */
	public static ArrayList<EntityParmToNet> registDataFormat(
			EntityRegist registEntity) {

		ArrayList<EntityParmToNet> registList = new ArrayList<EntityParmToNet>();

		// 用户名
		EntityParmToNet entityParmToNet1 = new EntityParmToNet("PhoneNo",
				registEntity.getPhoneNum());
		// 密码
		EntityParmToNet entityParmToNet2 = new EntityParmToNet("UserName",
				registEntity.getUserName());
		// 用户手机号
		EntityParmToNet entityParmToNet3 = new EntityParmToNet("PassWord",
				registEntity.getPassword());
		// 性别
		EntityParmToNet entityParmToNet4 = new EntityParmToNet("UserSex",
				registEntity.getmSex());
		// 生日
		EntityParmToNet entityParmToNet5 = new EntityParmToNet("FBirthDay",
				registEntity.getBirthday());
		// 身高
		EntityParmToNet entityParmToNet6 = new EntityParmToNet("UserHeight",
				registEntity.getUserHeight());
		// 体重
		EntityParmToNet entityParmToNet7 = new EntityParmToNet("UserWei",
				registEntity.getUserWei());
		// 邮箱
		EntityParmToNet entityParmToNet8 = new EntityParmToNet("FEMail",
				registEntity.getEmail());
		// 步幅
		EntityParmToNet entityParmToNet9 = new EntityParmToNet("FStepSize",
				registEntity.getTepSize());
		//
		EntityParmToNet entityParmToNet10 = new EntityParmToNet("FProfession",
				registEntity.getFProfession());
		//
		EntityParmToNet entityParmToNet11 = new EntityParmToNet("FRegion",
				registEntity.getFRegion());
		registList.add(entityParmToNet1);
		registList.add(entityParmToNet2);
		registList.add(entityParmToNet3);
		registList.add(entityParmToNet4);
		registList.add(entityParmToNet5);
		registList.add(entityParmToNet6);
		registList.add(entityParmToNet7);
		registList.add(entityParmToNet8);
		registList.add(entityParmToNet9);
		registList.add(entityParmToNet10);
		registList.add(entityParmToNet11);

		return registList;

		// RequestParams params = new RequestParams();
		// //用户名
		// params.addBodyParameter("PhoneNo",registEntity.getPhoneNum());
		// //密码
		// params.addBodyParameter("UserName", registEntity.getUserName());
		// //用户手机号
		// params.addBodyParameter("PassWord", registEntity.getPassword());
		// //性别
		// params.addBodyParameter("UserSex", registEntity.getmSex());
		// //生日
		// params.addBodyParameter("FBirthDay", registEntity.getBirthday());
		// //身高
		// params.addBodyParameter("UserHeight", registEntity.getUserHeight());
		// //体重
		// params.addBodyParameter("UserWei", registEntity.getUserWei());
		// //邮箱
		// params.addBodyParameter("FEMail", registEntity.getEmail());
		// //步幅
		// params.addBodyParameter("FStepSize", registEntity.getTepSize());
		// //
		// params.addBodyParameter("FProfession",registEntity.getFProfession());
		// //
		// params.addBodyParameter("FRegion", registEntity.getFRegion());

		// //用户名
		// params.addBodyParameter("PhoneNo","15024682630");
		// //密码
		// params.addBodyParameter("UserName", "ggdddg0");
		// //用户手机号
		// params.addBodyParameter("PassWord", "123");
		// // //性别
		// params.addBodyParameter("UserSex", "boy");
		// // //生日
		// params.addBodyParameter("FBirthDay", "1989-11-11");
		// // //身高
		// params.addBodyParameter("UserHeight", "202");
		// // //体重
		// params.addBodyParameter("UserWei", "60");
		// // //邮箱
		// params.addBodyParameter("FEMail", "66@qq.com");
		// // //步幅
		// params.addBodyParameter("FStepSize", "10");
		// // //
		// params.addBodyParameter("FProfession","h");
		// // //
		// params.addBodyParameter("FRegion", "");
		//

		// return params;
	}

	/**
	 * 登录信息封装方法
	 * 
	 * @param userName
	 *            用户名
	 * @param password
	 *            密码
	 * @return
	 */
	public static ArrayList<EntityParmToNet> loginDataFormat(
			EntityRegist loginEntity) {
		ArrayList<EntityParmToNet> loginList = new ArrayList<EntityParmToNet>();
		EntityParmToNet pair1 = new EntityParmToNet("userName",
				loginEntity.getUserName());
		EntityParmToNet pair2 = new EntityParmToNet("Password",
				loginEntity.getPassword());
		loginList.add(pair1);
		loginList.add(pair2);

		return loginList;
	}

	/**
	 * 用于封装修改用户的数据 在此App中可修改的字段为：UserHeight、FBirthDay(其他字段只显示不可修改)
	 * 其中的UserName和password为登录时候的值要携带过来。
	 * 
	 * @param userName
	 * @param password
	 * @param PhoneNO
	 * @param UserSex
	 * @param FBirthDay
	 * @param UserHeight
	 * @param UserWei
	 * @param FEMail
	 * @param FStepSize
	 * @param FProfession
	 * @param FRegion
	 * @return
	 */
	public List<NameValuePair> modificationDataFormat(
			EntityModification modificationEntity) {
		List<NameValuePair> modifList = new ArrayList<NameValuePair>();
		// UserName=string&PassWord=string&PhoneNo=string&UserSex=string&FBirthDay=string&UserHeight=string&UserWei=string&FEMail=string&FStepSize=string&FProfession=string&FRegion=string
		NameValuePair pair1 = new BasicNameValuePair("UserName",
				modificationEntity.getUserName());
		NameValuePair pair2 = new BasicNameValuePair("PassWord",
				modificationEntity.getPassword());
		NameValuePair pair3 = new BasicNameValuePair("PhoneNo",
				modificationEntity.getPhoneNO());
		NameValuePair pair4 = new BasicNameValuePair("UserSex",
				modificationEntity.getUserSex());
		NameValuePair pair5 = new BasicNameValuePair("FBirthDay",
				modificationEntity.getFBirthDay());
		NameValuePair pair6 = new BasicNameValuePair("UserHeight",
				modificationEntity.getUserHeight());
		NameValuePair pair7 = new BasicNameValuePair("UserWei",
				modificationEntity.getUserWei());
		NameValuePair pair8 = new BasicNameValuePair("FEMail",
				modificationEntity.getFEMail());
		NameValuePair pair9 = new BasicNameValuePair("FStepSize",
				modificationEntity.getFStepSize());
		NameValuePair pair10 = new BasicNameValuePair("FProfession",
				modificationEntity.getFProfession());
		NameValuePair pair11 = new BasicNameValuePair("FRegion",
				modificationEntity.getFRegion());
		modifList.add(pair1);
		modifList.add(pair2);
		modifList.add(pair3);
		modifList.add(pair4);
		modifList.add(pair5);
		modifList.add(pair6);
		modifList.add(pair7);
		modifList.add(pair8);
		modifList.add(pair9);
		modifList.add(pair10);
		modifList.add(pair11);

		return modifList;
	}

	/**
	 * 用于封装蓝牙传过来的数据， 此APP只上传 authkey（登录时获得的值）、visceralfat、weight 这三个数据，其他值为null
	 * 
	 * @param authkey
	 * @param muscle
	 * @param adiposerate
	 * @param visceralfat
	 * @param moisture
	 * @param bone
	 * @param thermal
	 * @param impedance
	 * @param bmi
	 * @param weight
	 * @param temperature
	 * @param heartrate
	 * @return
	 */
	public List<NameValuePair> uploadDataForMat(
			EntityUploadData uploadDataEntity) {
		List<NameValuePair> uploadList = new ArrayList<NameValuePair>();
		// authkey=string&muscle=string&adiposerate=string&visceralfat=string&moisture=string&bone=string&thermal=string&impedance=string&bmi=string&weight=string&temperature=string&heartrate=string
		NameValuePair pair1 = new BasicNameValuePair("authkey",
				uploadDataEntity.getAuthkey());
		NameValuePair pair2 = new BasicNameValuePair("muscle",
				uploadDataEntity.getMuscle());
		NameValuePair pair3 = new BasicNameValuePair("adiposerate",
				uploadDataEntity.getAdiposerate());
		NameValuePair pair4 = new BasicNameValuePair("visceralfat",
				uploadDataEntity.getVisceralfat());
		NameValuePair pair5 = new BasicNameValuePair("moisture",
				uploadDataEntity.getMoisture());
		NameValuePair pair6 = new BasicNameValuePair("bone",
				uploadDataEntity.getBone());
		NameValuePair pair7 = new BasicNameValuePair("thermal",
				uploadDataEntity.getThermal());
		NameValuePair pair8 = new BasicNameValuePair("impedance",
				uploadDataEntity.getImpedance());
		NameValuePair pair9 = new BasicNameValuePair("bmi",
				uploadDataEntity.getBmi());
		NameValuePair pair10 = new BasicNameValuePair("weight",
				uploadDataEntity.getWeight());
		NameValuePair pair11 = new BasicNameValuePair("temperature",
				uploadDataEntity.getTemperature());
		NameValuePair pair12 = new BasicNameValuePair("heartrate",
				uploadDataEntity.getHeartrate());

		return uploadList;
	}

	/**
	 * 用于重置用户数据
	 * 
	 * @param authkey
	 *            登录时候返回的值
	 * @param datatable
	 *            要删除的表格 此处写死5：代表服务器中的人体成分的表格
	 * @param data
	 *            传入当前时间的 eg 2014-11-25 21:27:50
	 * @param conditions
	 *            表示在传入的时间之前还是之后，此APP写死表示的意思是在此之前的数据全部清空
	 * @return
	 */
	public List<NameValuePair> removerDataFormat(
			EntityRemoverData removerDataEntity) {
		List<NameValuePair> removerList = new ArrayList<NameValuePair>();
		// authkey=string&datatable=string&date=string&conditions=string
		NameValuePair pair1 = new BasicNameValuePair("authkey",
				removerDataEntity.getAuthkey());
		NameValuePair pair2 = new BasicNameValuePair("datatable", "5");
		NameValuePair pair3 = new BasicNameValuePair("data",
				removerDataEntity.getData());
		NameValuePair pair4 = new BasicNameValuePair("conditions", "2");

		return removerList;
	}

	/**
	 * 用于查询体重和脂肪的数据
	 * 
	 * @param authkey
	 *            登录时带过来的值
	 * @param startdata
	 *            开始时间 eg 2013-06-23 12:56:23
	 * @param enddata
	 *            结束时间 eg 2015-02-05 21:35:42
	 * @return
	 */
	public List<NameValuePair> getBodyDataFormat(String authkey,
			String startdata, String enddata) {
		List<NameValuePair> bodyDataList = new ArrayList<NameValuePair>();
		// authkey=string&startdate=string&enddate=string
		NameValuePair pair1 = new BasicNameValuePair("authkey", authkey);
		NameValuePair pair2 = new BasicNameValuePair("startdate", startdata);
		NameValuePair pair3 = new BasicNameValuePair("enddate", enddata);

		return bodyDataList;
	}
}
